package tuvienna.jade.table;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class TableAgentGui extends JFrame {

	private static final long serialVersionUID = -2849417253007565147L;
	private TableAgent tableAgent;
    private JTextArea textArea;
    private JScrollPane receivedScrollPane;

    private static int count;
    
    private static synchronized int getNextCount() {
    	return count++;
    }
    
    public TableAgentGui(TableAgent pa) {
        super();
        tableAgent = pa;
        setTitle("GUI of "+tableAgent.getLocalName());
        setSize(200,300);
        int count = getNextCount();
        this.setLocation(10 +200 *(count % 5), 10 + 300 *(count / 5));
        
        JPanel mainPanel = new JPanel();
        
        textArea = new JTextArea(16,16);
        receivedScrollPane = new JScrollPane(textArea);
        mainPanel.add(receivedScrollPane, BorderLayout.CENTER);      
        //receivedMsgPanel.add(textArea, BorderLayout.CENTER);    
        mainPanel.setPreferredSize(new Dimension(400, 400));


        getContentPane().add(mainPanel, BorderLayout.CENTER);
    }

    public void setText(String text) {
        textArea.setText(text );
    }

}
